from enum import Enum


# 数据源
class CrawlSource(Enum):
    HEXUN = 'hexun'
    SINA = 'sina'
    TENCENT = 'tencent'
    EASTMONEY = 'eastmoney'


# 和讯

# 资产负债表、利润表、现金流量表、财务比率
# 输入：stockid=600000 reportdate=2019.03.15 2019.06.30 2019.90.30 2019.12.31 注意和讯网一季报日期是03.15
# 单位均为元，百分比率的需要乘以100
# 和讯的财务比率数据有缺失，不建议使用
HEXUN_FINANCIAL_ZCFZB = 'http://stockdata.stock.hexun.com/2008/zcfz.aspx?stockid={stockid}&accountdate={reportdate}'
HEXUN_FINANCIAL_LRB = 'http://stockdata.stock.hexun.com/2008/lr.aspx?stockid={stockid}&accountdate={reportdate}'
HEXUN_FINANCIAL_XJLLB = 'http://stockdata.stock.hexun.com/2008/xjll.aspx?stockid={stockid}&accountdate={reportdate}'
HEXUN_FINANCIAL_CWBL = 'http://stockdata.stock.hexun.com/2008/cwbl.aspx?stockid={stockid}&accountdate={reportdate}'


# 新浪

# 资产负债表、利润表、现金流量表、财务比率
# 输入：stockid=600000 reportyear=2019
# 资产负债表、利润表、现金流量表：单位为万元，财务比率：单位为元，百分比率的不需要乘以100
SINA_FINANCIAL_ZCFZB = 'http://money.finance.sina.com.cn/corp/go.php/vFD_BalanceSheet/stockid/{stockid}/ctrl/{reportyear}/displaytype/4.phtml'
SINA_FINANCIAL_LRB = 'https://money.finance.sina.com.cn/corp/go.php/vFD_ProfitStatement/stockid/{stockid}/ctrl/{reportyear}/displaytype/4.phtml'
SINA_FINANCIAL_XJLLB = 'https://money.finance.sina.com.cn/corp/go.php/vFD_CashFlow/stockid/{stockid}/ctrl/{reportyear}/displaytype/4.phtml'
SINA_FINANCIAL_CWBL = 'https://money.finance.sina.com.cn/corp/go.php/vFD_FinancialGuideLine/stockid/{stockid}/ctrl/{reportyear}/displaytype/4.phtml'


# 东财

# 财务报表发布日期
# 输入：pageno从1开始的分页号 pagesize=50 reportdate=2019-03-31 2019-06-30 2019-90-30 2019-12-31 rand=53266057随机数每次加1
EASTMONEY_FINANCIAL_NOTICE_DATE = 'http://datacenter.eastmoney.com/api/data/get?type=RPT_LICO_FN_CPD&sty=ALL&p={pageno}&ps={pagesize}&st=UPDATE_DATE,SECURITY_CODE&sr=-1,-1&var=BSoAyPHj&filter=(SECURITY_TYPE_CODE=%22058001001%22)(REPORTDATE=%27{reportdate}%27)&rt={rand}'
#EASTMONEY_FINANCIAL_NOTICE_DATE = 'http://datacenter.eastmoney.com/api/data/get?type=RPT_PUBLIC_BS_APPOIN&sty=ALL&p={pageno}&ps={pagesize}&st=FIRST_APPOINT_DATE,SECURITY_CODE&sr=1,1&var=MYcOmBoi&filter=(REPORT_DATE=%27{reportdate}%27)&rt={rand}'

# 机构研报
# 输入：rand=4914402随机数每次加1 begin_date=2020-03-13 end_date=2020-09-13 pageno从1开始的分页号 pagesize=100 timestamp=1599990409370毫秒时间戳
EASTMONEY_RESEARCH_REPORT = 'http://reportapi.eastmoney.com/report/list?cb=datatable{rand}&industryCode=*&pageSize={pagesize}&industry=*&rating=*&ratingChange=*&beginTime={begin_date}&endTime={end_date}&pageNo={pageno}&fields=&qType=0&orgCode=&code=*&rcode=&p={pageno}&_={timestamp}'

# 近3年估值百分位URL：pe30,pe50,pe70
# 参数：code: 股票代码+交易所编码，例如：上交所股票：60000101；深交所：00000102,30022102
EASTMONEY_PE_PERCENTAGE_URL = 'https://emh5.eastmoney.com/API_HSF10/CPBD/GZFX?code={code}&type=1&year=2'

# 业绩预告、快报
# 业绩预告，参数：pageno从1开始的分页号 pagesize=100 reportdate=2019-03-31 2019-06-30 2019-90-30 2019-12-31 rand=53359066随机数每次加1
EASTMONEY_FINANCIAL_YJYG = 'http://datacenter.eastmoney.com/api/data/get?type=RPT_PUBLIC_OP_PREDICT&sty=ALL&p={pageno}&ps={pagesize}&st=NOTICE_DATE,SECURITY_CODE&sr=-1,-1&var=cSSQORwc&filter=(REPORTDATE=%27{reportdate}%27)(IsLatest=%22T%22)&rt={rand}'
# 业绩快报，参数：pageno从1开始的分页号 pagesize=100 reportdate=2019-03-31 2019-06-30 2019-90-30 2019-12-31 rand=53359044随机数每次加1
EASTMONEY_FINANCIAL_YJKB = 'http://datacenter.eastmoney.com/api/data/get?type=RPT_FCI_PERFORMANCEE&sty=ALL&p={pageno}&ps={pagesize}&st=UPDATE_DATE,SECURITY_CODE&sr=-1,-1&var=EOWpZXXh&filter=(REPORT_DATE=%27{reportdate}%27)&rt={rand}'


# 腾讯

# 股票日行情 参数：code sh600519 sz300003
# 返回结果：以 ~ 分割字符串中内容
"""
v_sh600519="1~贵州茅台~600519~358.74~361.29~361.88~27705~12252~15453~358.75~8~358.74~4~358.72~7~358.71~6~358.70~5~358.77~3~358.78~2~358.79~16~358.80~4~358.86~1~14:59:59/358.75/5/S/179381/28600|14:59:56/358.75/1/S/35875/28594|14:59:53/358.75/1/S/35875/28588|14:59:50/358.75/1/S/35875/28579|14:59:47/358.75/4/B/143499/28574|14:59:41/358.72/4/S/143501/28562~20170221150553~-2.55~-0.71~362.43~357.18~358.75/27705/994112865~27705~99411~0.22~27.24~~362.43~357.18~1.45~4506.49~4506.49~6.57~397.42~325.16~0.86";
"""
# 下标从0开始，依次为：
"""
 1  0: 未知
 2  1: 股票名字
 3  2: 股票代码
 4  3: 当前价格
 5  4: 昨收
 6  5: 今开
 7  6: 成交量（手）
 8  7: 外盘
 9  8: 内盘
10  9: 买一
11 10: 买一量（手）
12 11-18: 买二 买五
13 19: 卖一
14 20: 卖一量
15 21-28: 卖二 卖五
16 29: 最近逐笔成交
17 30: 时间
18 31: 涨跌
19 32: 涨跌%
20 33: 最高
21 34: 最低
22 35: 价格/成交量（手）/成交额
23 36: 成交量（手）
24 37: 成交额（万）
25 38: 换手率
26 39: 市盈率
27 40: 
28 41: 最高
29 42: 最低
30 43: 振幅
31 44: 流通市值
32 45: 总市值
33 46: 市净率
34 47: 涨停价
35 48: 跌停价
"""
TENCENT_STOCK_DAY = 'http://qt.gtimg.cn/q={code}'

# header

HEADER = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36'
}
